import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { createHtmlPlugin } from "vite-plugin-html";
import path from "path";
// https://vite.dev/config/
export default defineConfig(() => {
  return {
    plugins: [
      createHtmlPlugin({
        inject: {
          data: {
            title: "在线刷题后台管理",
          },
        },
      }),
      vue(),
    ],
    build: {
      outDir: "dist",
    },
    css: {
      preprocessorOptions: {
        less: {
          charset: false,
          additionalData: '@import "src/static/styles/variables.less";',
        },
      },
    },
    resolve: {
      alias: {
        "@": path.resolve(__dirname, "src"),
      },
    },
    server: {
      host: "127.0.0.1",
      port: 8080,
      hmr: true,
      proxy: {
        "/api": {
          target: "http://manage.lovedong.work",
          // target: "http://127.0.0.1:3003",
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, ""),
        },
        "/static": {
          target: "http://manage.lovedong.work",
          // target: "http://127.0.0.1:3003",
          changeOrigin: true,
        },
      },
    },
  };
});
